package com.ningxun.pagent.web.controller.teenage;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ningxun.pagent.common.annotation.Log;
import com.ningxun.pagent.common.core.controller.BaseController;
import com.ningxun.pagent.common.core.domain.AjaxResult;
import com.ningxun.pagent.common.enums.BusinessType;
import com.ningxun.pagent.bus.domain.wechatuser.BaseWechatUser;
import com.ningxun.pagent.bus.service.basewechatuser.IBaseWechatUserService;
import com.ningxun.pagent.common.utils.poi.ExcelUtil;
import com.ningxun.pagent.common.core.page.TableDataInfo;

/**
 * 青年管理模块Controller
 * 
 * @author pagent
 * @date 2025-07-09
 */
@RestController
@RequestMapping("/teenage/teenage")
public class BaseWechatUserController extends BaseController
{
    @Autowired
    private IBaseWechatUserService baseWechatUserService;

    /**
     * 查询青年管理模块列表
     */
    @PreAuthorize("@ss.hasPermi('teenage:teenage:list')")
    @GetMapping("/list")
    public TableDataInfo list(BaseWechatUser baseWechatUser)
    {
        startPage();
        List<BaseWechatUser> list = baseWechatUserService.selectBaseWechatUserList(baseWechatUser);
        return getDataTable(list);
    }

    /**
     * 导出青年管理模块列表
     */
    @PreAuthorize("@ss.hasPermi('teenage:teenage:export')")
    @Log(title = "青年管理模块", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BaseWechatUser baseWechatUser)
    {
        List<BaseWechatUser> list = baseWechatUserService.selectBaseWechatUserList(baseWechatUser);
        ExcelUtil<BaseWechatUser> util = new ExcelUtil<BaseWechatUser>(BaseWechatUser.class);
        util.exportExcel(response, list, "青年管理模块数据");
    }

    /**
     * 获取青年管理模块详细信息
     */
    @PreAuthorize("@ss.hasPermi('teenage:teenage:query')")
    @GetMapping(value = "/{userId}")
    public AjaxResult getInfo(@PathVariable("userId") Long userId)
    {
        return success(baseWechatUserService.selectBaseWechatUserByUserId(userId));
    }

    /**
     * 新增青年管理模块
     */
    @PreAuthorize("@ss.hasPermi('teenage:teenage:add')")
    @Log(title = "青年管理模块", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BaseWechatUser baseWechatUser)
    {
        return toAjax(baseWechatUserService.insertBaseWechatUser(baseWechatUser));
    }

    /**
     * 修改青年管理模块
     */
    @PreAuthorize("@ss.hasPermi('teenage:teenage:edit')")
    @Log(title = "青年管理模块", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BaseWechatUser baseWechatUser)
    {

        return toAjax(baseWechatUserService.updateBaseWechatUser(baseWechatUser));
    }

    /**
     * 修改用户状态方法
     */
    @PreAuthorize("@ss.hasPermi('teenage:teenage:edit')")
    @Log(title = "青年管理模块", businessType = BusinessType.UPDATE)
    @PutMapping("/updataStatusByuserid/{id}/{userStatus}")
    public AjaxResult updataStatusByuserid(@PathVariable long id , @PathVariable long userStatus){
        return toAjax(baseWechatUserService.updataStatusByuserid(id , userStatus));
    }
    /**
     * 删除青年管理模块
     */
    @PreAuthorize("@ss.hasPermi('teenage:teenage:remove')")
    @Log(title = "青年管理模块", businessType = BusinessType.DELETE)
	@DeleteMapping("/{userIds}")
    public AjaxResult remove(@PathVariable Long[] userIds)
    {
        return toAjax(baseWechatUserService.deleteBaseWechatUserByUserIds(userIds));
    }
}
